import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
//1.定义路由组件
import Home from '@/views/Home.vue'
import Find from '@/views/Find.vue'
//2.定义路由配置选项
const routes = [
  {
    path: "/",
    redirect: { name: "home" },
  },
  {
    path: "/home",
    name: 'home',
    component: Home,
  },
  {
    path: "/find",
    name: 'find',
    component: Find,
  },
  {
    path: "/mine",
    name: 'mine',
    component: () => import('@/views/Mine.vue'),
  },
  {
    path: "/ajax",
    name: 'ajax',
    component: () => import('@/views/Ajax.vue'),
  },
  {
    path: "/axios",
    name: 'axios',
    component: () => import('@/views/Axios.vue'),
  },
  {
    path:"/vuex",
    name:'vuex',
    component:()=>import('@/views/Vuex.vue'),
  },
  {
    path: "/404",
    name: "notfound",
    component: () => import('@/views/404.vue'),
  },
  {
    path: "*",
    redirect: "/404",
  }
]
//3.创建路由对象
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 4.挂载到根实例
export default router
